package util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class ConncetionUtil {

    public static   Connection getConnection(){
        //创建connection工厂
        ConnectionFactory factory  = new ConnectionFactory();
        factory.setHost("10.9.45.229");
        factory.setPort(5672);
        factory.setUsername("test");
        factory.setPassword("test");
        factory.setVirtualHost("/");

        //创建连接
        Connection connection=null;
        try {
             connection = factory.newConnection();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        }
        return connection;
    }

}
